﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ZedGraph;

namespace NumMethods_HW1_HeatEquation
{
    public partial class MainForm : Form
    {
        HeatEquation eq;
        int n;
        int m;
        double xLeft, xRight;
        double T;
        int graphicTime;

        public MainForm()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            groupBoxPrepare.Enabled = true;
            groupBoxGraphics.Enabled = false;
        }

        private void numericUpDownGraphicTime_ValueChanged(object sender, EventArgs e)
        {
           // numericUpDownGraphicTime.Maximum = m;
            //graphicTime = Convert.ToInt32(numericUpDownGraphicTime.Value);
            //eq.DrawGraphic(zedGraphControl, graphicTime);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            groupBoxGraphics.Enabled = true;

            n = Convert.ToInt32(numericUpDownN.Value);
            m = Convert.ToInt32(numericUpDownM.Value);
            xLeft = 0;
            xRight = 1;
            T = 1;

            eq = new HeatEquation(n, m, xLeft, xRight, T);

            eq.CalculateTemperature();

            //graphicTime = Convert.ToInt32(numericUpDownGraphicTime.Value);
            //eq.DrawGraphic(zedGraphControl, graphicTime);

            groupBoxGraphics.Enabled = true;
            numericUpDownGraphicTime.Maximum = m;
            clearGraphics();
        }

        private void clearGraphics()
        {
            GraphPane pane = zedGraphControl.GraphPane;
            pane.CurveList.Clear();
            zedGraphControl.Invalidate();
        }

        private void btnPlot_Click(object sender, EventArgs e)
        {
            graphicTime = Convert.ToInt32(numericUpDownGraphicTime.Value);
            eq.DrawGraphic(zedGraphControl, graphicTime);
        }
    }
}
